package com.dbappsecurity.jsbridge.entity;

import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.parceler.Parcel;

/**
 * Created by Arirus on 2017/7/21.
 */

@Parcel(analyze = {jsGroupItems.class})
public class jsGroupItems extends jsBaseEntity {
  @SerializedName("item") ArrayList<jsBaseItem> itemList;
  String msg;
  @SerializedName("buttonType") String type; //optionBtn 左右类型
  String title;

  public List<jsBaseItem> getItemList() {

    ArrayList<jsBaseItem> list = (ArrayList<jsBaseItem>)(itemList.clone());
    Collections.sort(list, new Comparator<jsBaseItem>() {
      @Override
      public int compare(jsBaseItem o1, jsBaseItem o2) {
        if (o1.getTag()==null || o2.getTag() == null) return -1;
        int tag1 = Integer.parseInt(o1.getTag());
        int tag2 = Integer.parseInt(o2.getTag());
        if (tag1<tag2) return -1;
        else if (tag1>tag2) return 1;
        return 0;
      }
    });
    return list;
  }

  public void setItemList(ArrayList<jsBaseItem> itemList) {
    this.itemList = itemList;
  }

  public String getMsg() {
    return msg;
  }

  public void setMsg(String msg) {
    this.msg = msg;
  }

  public String getType() {
    return type;
  }

  public void setType(String type) {
    this.type = type;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }
}
